package gptma.bo.services.scheduling;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// GF bug "MessageDriven cannot be a managed bean"
// @MessageDriven(mappedName="jms/Topic")
public class TopicListener implements MessageListener {

	private static final Logger log = LoggerFactory.getLogger(TopicListener.class);

	@Override
	public void onMessage(Message msg) {
		log.debug("Begin({})", msg);

		TextMessage tm = (TextMessage) msg;
		try {
			log.info("Java TopicListener received following message: {}", tm.getText());
		} catch (JMSException e) {
			log.error("Could not read message from JMS topic, error code: {}, msg: {}",
					e.getErrorCode(), e.getMessage());
		}

		log.debug("End");
	}

}
